﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hive.Bot.Tasks;
using Hive.Core;

namespace Hive.Bot.Behaviours
{
    public class FarmBehavior: IBehaviour
    {
        public static Dictionary<Location, int[,]> calculations = new Dictionary<Location, int[,]>();

        public List<ITask> GenerateTasks()
        {
            calculations = new Dictionary<Location, int[,]>();
            ProcessCalculations();
            var result = new List<ITask>();

            foreach (var f in Env.Food)
            {
                result.Add(new GatherTask(f, calculations[f]));
            }
            return result;
        }

        private void ProcessCalculations()
        {
            foreach (var f in Env.Food)
            {
                if (!calculations.ContainsKey(f))
                {
                    calculations[f] = Env.Map.FillPathCalculation(f, int.MaxValue);//Env.Map.FillPathCalculation(f, Env.ViewRadius + 2);
                }
            }
        }
    }
}

